package com.chinasofti.zbest.service.impl;

import com.chinasofti.zbest.dao.model.User;
import com.chinasofti.zbest.dao.model.UserAddr;
import com.chinasofti.zbest.dao.UserAddrMapper;
import com.chinasofti.zbest.service.IUserAddrService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chinasofti.zbest.service.info.UserAddrInfo;
import com.chinasofti.zbest.web.form.UserAddFrom;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户地址表 服务实现类
 * </p>
 *
 * @author zbest
 * @since 2019-05-28
 */
@Service
@Slf4j
public class UserAddrServiceImpl extends ServiceImpl<UserAddrMapper, UserAddr> implements IUserAddrService {

    @Autowired
    private UserAddrMapper userAddrMapper;

    @Override
    public void add(UserAddrInfo userAddr1) {
        UserAddr userAddr2 = new UserAddr();
        BeanUtils.copyProperties(userAddr1, userAddr2);
        System.out.println(userAddr2);

        userAddrMapper.insert(userAddr2);    }



    @Override
    public List<UserAddr> findByIdAddr(Integer userId) {
        return userAddrMapper.findByIdAddr(userId);
    }

    public List<UserAddr> queryAllByAddrId(Integer userId){

        log.info("userId.toString():"+userId.toString());
        List<UserAddr> userAddrs = userAddrMapper.queryAllByAddrId(userId);

        return userAddrs;
    }



    @Override
    public UserAddr queryOneUserAddrUn(Integer userId) {

        UserAddr userAddr = userAddrMapper.queryOneUserAddrUn(userId);
        return userAddr;
    }

    @Override
    public List<UserAddFrom> queryAllById(Integer userId) {
        return null;
    }
}
